<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class chucvu_db 
	{
		public function Them($MaChucVu, $TenChucVu, $GhiChu)
		{
			$sql = "INSERT INTO `tbl_chucvu`(`MaChucVu`, `TenChucVu`, `GhiChu`)
					VALUES ('$MaChucVu', '$TenChucVu', '$GhiChu')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaChucVu)
		{
			$sql = "DELETE FROM `tbl_chucvu` WHERE `MaChucVu` = '$MaChucVu'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaChucVu, $TenChucVu, $GhiChu)
		{
			$sql = "UPDATE `tbl_chucvu`
					SET `TenChucVu` = '$TenChucVu', `GhiChu` = '$GhiChu'
					WHERE `MaChucVu` = '$MaChucVu'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaChucVu, $TenChucVu, $GhiChu)
		{
			$sql = "SELECT * FROM `tbl_chucvu` WHERE 1  ";
			if($MaChucVu != "")
				$sql .= " AND `MaChucVu` = '$MaChucVu' ";

			if($TenChucVu != "")
				$sql .= " AND `TenChucVu` = '$TenChucVu' ";

			if($GhiChu != "")
				$sql .= " AND `GhiChu` = '$GhiChu' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

